;function FloatingBubble(container, content, options) {
    var $this = this;
    var defaults = $.extend(options,{
        delay:50,
        speed:1,
        width:100,
        height:100,
        onClick:function () {

        }
    });

    var $container = $(container);
    var width  = $container.width() - defaults.width;
    var height = $container.height() - defaults.height;
    var speedX = defaults.speed;
    var speedY = defaults.speed;
    var posX = Math.round(Math.random()*width);
    var posY = Math.round(Math.random()*height);

    var bubble = $("<div/>").html('<div>'+content+'</div>').css({
        'position':'absolute',
        'z-index':FloatingBubble.zIndex++,
        'left':posX+'px',
        'top':posY+'px'
    });
    $(container).append(bubble);
    bubble.on('click', function () {
        if (defaults.onClick) defaults.onClick($this);
    });

    this.float = function () {
        if(posX<0||posX>width) {
            speedX = -speedX;
        }
        if(posY<0||posY>height) {
            speedY = -speedY;
        }

        posX+= speedX;
        posY+= speedY;
        bubble.css({
            left:posX+'px',
            top:posY+'px',
        });
    };

    this.hide = function () {
        bubble.hide();
    };

    this.remove = function () {
        bubble.remove();
    };

    this.getRandomNum = function (Min, Max){
        var Range = Max - Min;
        var Rand = Math.random();
        return(Min + Math.round(Rand * Range));
    };
    speedX = this.getRandomNum(0, 1) ? speedX : -speedX;
    speedY = this.getRandomNum(0, 1) ? speedY : -speedY;
    this.interval = setInterval(this.float, defaults.delay);
}

FloatingBubble.zIndex = 1000;
